/**
 * Created by roger on 2017/4/19.
 */
var gulp = require("gulp");

var ts = require("gulp-typescript");
var tsProject = ts.createProject("tsconfig.json");


var browserify = require("browserify");
var source = require("vinyl-source-stream");
var tsify = require("tsify");

var paths ={
    pages:[
        'app/**/*']
};

gulp.task("tsc",function () {
    return tsProject.src()
        .pipe(tsProject())
        .js.pipe(gulp.dest("app"));
});

gulp.task("copy-app", function () {
    return gulp.src(paths.pages)
        .pipe(gulp.dest("dist"));
});


gulp.task("default", ["tsc","copy-app"], function () {
    return browserify({
        basedir: '.',
        debug: true,
        entries: ['app/maintest.ts'],
        cache: {},
        packageCache: {}
    })
        .plugin(tsify)
        .bundle()
        .pipe(source('bundle.js'))
        .pipe(gulp.dest("dist"));
});